<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>在Windows配置Centos服务器实现Android项目远程打包 - smartzheng</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="smartzheng" /><meta name="description" content="0.需求 平时开发测试环节中涉及多次回归测试，于是考虑对服务器进行配置，当开发完后每次push代码，测试部门即可从服务器打包pull进行测试。" /><meta name="keywords" content="Hugo, theme, even" />






<meta name="generator" content="Hugo 0.68.3 with theme even" />


<link rel="canonical" href="https://smartzheng.github.io/post/%E5%9C%A8windows%E9%85%8D%E7%BD%AEcentos%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%9E%E7%8E%B0android%E9%A1%B9%E7%9B%AE%E8%BF%9C%E7%A8%8B%E6%89%93%E5%8C%85/" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">


<link href="/dist/even.c2a46f00.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="在Windows配置Centos服务器实现Android项目远程打包" />
<meta property="og:description" content="0.需求 平时开发测试环节中涉及多次回归测试，于是考虑对服务器进行配置，当开发完后每次push代码，测试部门即可从服务器打包pull进行测试。" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://smartzheng.github.io/post/%E5%9C%A8windows%E9%85%8D%E7%BD%AEcentos%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%9E%E7%8E%B0android%E9%A1%B9%E7%9B%AE%E8%BF%9C%E7%A8%8B%E6%89%93%E5%8C%85/" />
<meta property="article:published_time" content="2017-09-29T00:00:00+00:00" />
<meta property="article:modified_time" content="2017-09-29T00:00:00+00:00" />
<meta itemprop="name" content="在Windows配置Centos服务器实现Android项目远程打包">
<meta itemprop="description" content="0.需求 平时开发测试环节中涉及多次回归测试，于是考虑对服务器进行配置，当开发完后每次push代码，测试部门即可从服务器打包pull进行测试。">
<meta itemprop="datePublished" content="2017-09-29T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2017-09-29T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="678">



<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="在Windows配置Centos服务器实现Android项目远程打包"/>
<meta name="twitter:description" content="0.需求 平时开发测试环节中涉及多次回归测试，于是考虑对服务器进行配置，当开发完后每次push代码，测试部门即可从服务器打包pull进行测试。"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">smartzheng</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">Categories</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">smartzheng</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">Home</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">Categories</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">在Windows配置Centos服务器实现Android项目远程打包</h1>

      <div class="post-meta">
        <span class="post-time"> 2017-09-29 </span>
        <div class="post-category">
            <a href="/categories/android/"> Android </a>
            </div>
        
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li></li>
      </ul>
    </li>
  </ul>
</nav>
  </div>
</div>
    <div class="post-content">
      <h4 id="0需求">0.需求</h4>
<p>平时开发测试环节中涉及多次回归测试，于是考虑对服务器进行配置，当开发完后每次push代码，测试部门即可从服务器打包pull进行测试。</p>
<h4 id="1连接服务器">1.连接服务器</h4>
<p>我用的是PuTTY 进行连接，软件可自行Google下载，安装完成之后填写id和password即可登录到CentOs服务器。（本文CentOS的版本为6.8，且已配置好JDK）</p>
<h4 id="2配置androidsdk">2.配置AndroidSDK</h4>
<h5 id="1下载sdktools">1）下载sdktools</h5>
<ul>
<li>进入etc，创建文件夹</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">cd /etc  
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">mkdir androidSdk
</code></pre></td></tr></table>
</div>
</div><ul>
<li>下载，解压</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip  
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">unzip sdk-tools-linux-3859397.zip 
</code></pre></td></tr></table>
</div>
</div><h5 id="2配置环境变量">2）配置环境变量</h5>
<ul>
<li>打开etc目录下的profile</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">cd etc
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">vi profile
</code></pre></td></tr></table>
</div>
</div><ul>
<li>打开后输入i进入编辑模式，在文件末尾插入以下命令</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">export PATH=$PATH:/etc/androidSdk/tools/bin
</code></pre></td></tr></table>
</div>
</div><ul>
<li>esc退出编辑，:w进行保存，:q退出文件</li>
<li>执行：<code>source profile  </code> 生效</li>
<li>执行<code>sdkmanager</code>检查是否安装成功</li>
</ul>
<h5 id="3安装必要的package">3）安装必要的package</h5>
<ul>
<li>根据需要执行安装以下的package
build-tools;25.0.3             <br>
emulator                <br>
extras;android;m2repository
patcher;v4              <br>
platform-tools                 <br>
platforms;android-25         <br>
tools <br>
安装命令为：<code>sdkmanager &quot;build-tools;26.0.0&quot;</code><br>
将命令中的build-tools;26.0.0依次替换为上面的包名称+版本号可依次安装，也可选择需要的版本。</li>
</ul>
<h5 id="4配置platform-tools">4）配置platform tools</h5>
<ul>
<li>在etc/profile中添加以下命令，方法同上面配置tools<br>
<code>export PATH=$PATH:/etc/androidSdk/platform-tools</code></li>
<li>配置完成后可以执行adb命令检查</li>
</ul>
<h4 id="3配置gradle">3.配置gradle</h4>
<h5 id="1下载">1）下载</h5>
<ul>
<li>进入etc，创建文件夹</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">cd /etc  
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">mkdir gradle
</code></pre></td></tr></table>
</div>
</div><ul>
<li>下载，解压</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">wget https://services.gradle.org/distributions/gradle-4.0.1-bin.zip  
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">unzip gradle-4.0.1-bin.zip 
</code></pre></td></tr></table>
</div>
</div><h5 id="2配置gradle">2）配置gradle</h5>
<ul>
<li>在etc/profile中添加以下命令，方法同上面配置tools</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">export PATH=$PATH:/etc/gradle/gradle-4.0.1/bin
</code></pre></td></tr></table>
</div>
</div><ul>
<li>配置完成后可以执行gradle命令检查</li>
</ul>
<h4 id="4配置git">4.配置git</h4>
<ul>
<li>直接执行<br>
<code>yum install git</code></li>
</ul>
<h4 id="5完成">5.完成</h4>
<ul>
<li>接下来可以直接pull代码，进入到项目根目录执行<code>gradle assRelease</code>打包。</li>
</ul>

    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">smartzheng</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2017-09-29
        
    </span>
  </p>
  
  
</div>
<footer class="post-footer">
      
      <nav class="post-nav">
        <a class="prev" href="/post/%E6%B1%9F%E6%AD%8C%E6%A1%88%E5%92%8C%E8%88%86%E8%AE%BA%E7%9A%84%E9%80%BB%E8%BE%91/">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">江歌案和舆论的逻辑</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/post/android%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90%E4%B9%8B%E6%B5%85%E6%9E%90android%E7%B3%BB%E7%BB%9F%E5%90%AF%E5%8A%A8%E8%BF%87%E7%A8%8B/">
            <span class="next-text nav-default">Android源码分析之浅析Android系统启动过程</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        

  

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:smartzheng1993@email.com" class="iconfont icon-email" title="email"></a>
      <a href="https://github.com/smartzheng" class="iconfont icon-github" title="github"></a>
      <a href="https://weibo.com/2062336885/profile?topnav=1&amp;wvr=6" class="iconfont icon-weibo" title="weibo"></a>
      <a href="https://www.zhihu.com/people/liu-xia-hui-89-70" class="iconfont icon-zhihu" title="zhihu"></a>
      <a href="https://www.douban.com/people/smartzheng/" class="iconfont icon-douban" title="douban"></a>
  <a href="https://smartzheng.github.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  

  <span class="copyright-year">
    &copy; 
    2017 - 
    2020
    
  </span>
</div>
    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>
<script type="text/javascript" src="/dist/even.26188efa.min.js"></script>








</body>
</html>
